package homework.score;

public enum Course {

    CHINESE("语文"), MATH("数学"), ENGLISH("英语");

    private String name;
    private Double maxScore;
    private Double minScore;

    private Course(String name, double maxScore, double minScore) {
        this.name = name;
        this.maxScore = maxScore;
        this.minScore = minScore;
    }

    private Course(String name) {
        this(name, 100, Double.NEGATIVE_INFINITY);
    }

    public boolean validate(double score) {
        return score >= minScore && score <= maxScore;
    }

    public Course getCourse(String name) {
        for (Course each : values()) {
            if (each.toString().equals(name)) {
                return each;
            }
        }

        throw new IllegalArgumentException(name);
    }

    @Override
    public String toString() {
        return name;
    }
}
